package com.zbkj.admin;

import com.tiangong.framework.enable.EnableEventHandler;
//import com.tiangong.framework.enable.EnableOpenApiDoc;
import com.tiangong.framework.enable.EnableRedisDynamic;
import com.tiangong.framework.enable.EnableRestController;
import com.tiangong.framework.util.Utils;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 程序主入口
 */
@EnableAsync //开启异步调用
@Configuration
//@EnableSwagger2
//@EnableOpenApiDoc
@EnableTransactionManagement
@SpringBootApplication//(exclude = DataSourceAutoConfiguration.class) //去掉数据源
@ComponentScan(basePackages = {"com.zbkj"})
@MapperScan(basePackages = {"com.zbkj.**.dao","com.zbkj.business.**.**"})
@EnableRestController
@EnableRedisDynamic
@EnableEventHandler
@EnableScheduling
@Slf4j
public class AdminApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext application =SpringApplication.run(AdminApplication.class, args);

        Environment env = application.getEnvironment();

        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path")==null?"/":env.getProperty("server.servlet.context-path");

        log.info("\n----------------------------------------------------------\n\t" +
                "Application is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "api/rest/v1/serviceName/methodName\n\t" +
                "External: \thttp://"+ Utils.getLanIpAddresses()+":"+port+path+"api/rest/v1/serviceName/methodName\n" +
                "----------------------------------------------------------");
    }

}
